package com.lmx.repoDomain.tmodel;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToOne;

/**
 * 老人活动方案项目表
 * @author luganli
 */
@JsonApiResource(type = "customeractivityprojectitem")
@Table(name = "tnb_customer_activity_project_item")
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class CustomerActivityProjectItem extends BaseEntity {

	private Integer createDateTime;// 创建时间
	
	private CustomerActivityServiceItem item;// 活动项目ID
	
	private CustomerActivityProject project;// 老人活动方案表ID
	
	private String remark;// 备注
	
	private Customer customer; // 创建人
	
	private User createUser; // 创建人

	private Integer lastUpdateDateTime;// 更新时间
	
	private Dicttype period;// 周期

	private String frequency;// 频次
	
	@Column(name = "frequency")
	public String getFrequency() {
		return frequency;
	}

	public void setFrequency(String frequency) {
		this.frequency = frequency;
	}
	
	@JsonApiToOne
	@JsonApiIncludeByDefault
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "period_id", foreignKey = @ForeignKey(name = "null"))
	public Dicttype getPeriod() {
		return period;
	}

	public void setPeriod(Dicttype period) {
		this.period = period;
	}

	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}
	
	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}
	
	public void setRemark(String remark) {
		this.remark = remark;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
    @Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "customer_id", foreignKey = @ForeignKey(name = "null"))
	public Customer getCustomer() {
		return customer;
	}

	public void setCustomer(Customer customer) {
		this.customer = customer;
	}
	
	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}
	
	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@JsonApiToOne
	@JsonApiIncludeByDefault
    @Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "activityServiceItemID", foreignKey = @ForeignKey(name = "null"))
	public CustomerActivityServiceItem getItem() {
		return item;
	}

	public void setItem(CustomerActivityServiceItem item) {
		this.item = item;
	}
	
	@JsonApiToOne
	@JsonApiIncludeByDefault
    @Fetch(FetchMode.JOIN)
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "activityProjectID", foreignKey = @ForeignKey(name = "null"))
	public CustomerActivityProject getProject() {
		return project;
	}
	
	public void setProject(CustomerActivityProject project) {
		this.project = project;
	}
	
	@Column(name = "lastUpdateDateTime")
	public Integer getLastUpdateDateTime() {
		return lastUpdateDateTime;
	}

	public void setLastUpdateDateTime(Integer lastUpdateDateTime) {
		this.lastUpdateDateTime = lastUpdateDateTime;
	}
}
